package com.owdp.code.controller;

import com.owdp.code.entity.User;
import com.owdp.code.service.UserPimService;
import com.owdp.code.utils.MD5Utils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

@RestController
@RequestMapping("/UserPim")
public class UserPimController {
    @Resource
    UserPimService userPimService;

    @PostMapping("/changepwd")
    public String changepwd(String account, String userpassword) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        //通过前端获取session保存的密码判断原密码输入是否正确，然后再确认新密码是否一样最后把新密码传值到后台
        //后端只进行修改操作，获取到新密码和账户即可
        String password= MD5Utils.getEncryptedPwd(userpassword);//加密密码
        userPimService.updatePwd(account, password);
        return "修改成功";
    }
    @PostMapping("/changecpnumber")
    public String changecpnumber(){
        return "";
    }
}
